﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using AutonomicComputingLibrary.Helpers;

namespace AutonomicComputingLibrary.MAPE
{
   public class Analyze
    {
          private Plan p = null; 
        public Analyze()
        {
            p = new Plan();

        }


       

       public void Error(string _class)
       {

           p.SortPlans(_class);

       }
       
       public void ALertPlan()
       {
           

       }

       
       //did we succeed, did the sitution get better if so by how much give 1 point for every percentage point increase
        public void AddRank(Guid id)
        {


        }

        /// <summary>
        /// Add initial instances to fail
        /// </summary>
        /// <param name="Class"></param>
        /// <param name="method"></param>
        /// 
        //use this to write the new style to file method class from list
        public void AddAllMethodsToFile(string Class, string method)
        {
            var xml = new XMLManager();
            //  xml.AddLogEntry("TEST.XML", "TEST323", 0.ToString());
             // xml.AddLogEntry(Class, method, 0.ToString());

        }

        //go through classes, check if file exists if not create
        public void InitConfig(string subsystem, List<Tuple<dynamic, string>> MappingList)
        {
           

            string ns = "AutonomicComputingLibrary.CHOP";
            var xml = new XMLManager();
            //  xml.AddLogEntry("TEST.XML", "TEST323", 0.ToString());
            
                foreach(var item in MappingList)
                {
                   
                        xml.AddLogEntry(subsystem.ToString(), item.Item1.ToString(), item.Item2, 0.ToString());
                    
                }
        }

        //need a way to match chop and util

        //a way to store previous error and match to what worked create a matching xml file


        /// <summary>
        /// Get all namespace in file
        /// </summary>
        /// <param name="_namespace"></param>
        /// <returns></returns>
     


        /// <summary>
        /// Get Methods to write to file
        /// </summary>
        /// <param name="_class"></param>
        /// <returns></returns>
        public List<MethodInfo> GetMethods(dynamic _class)
        {
            // get all public static methods of MyClass type
            MethodInfo[] methodInfos = _class.GetMethods();

           return methodInfos.ToList();


        }








    }
}
